package com.hunttown.mes.rpc.domain.enums.task;

import java.util.HashMap;
import java.util.Map;

/**
 * 任务状态：0新任务 1已阅读 2进行中 4已完成 10拒绝 20放弃 30失效 40关闭
 * created by wangjunfu on 2018/11/6
 */
public enum TaskStatusEnum {
    CAOGAO(0, "新任务"),
    NONE(1, "已阅读"),
    WORKING(2, "进行中"),
    DONE(4, "已完成 "),
    REJECT(10, "拒绝"),
    ABANDON(20, "放弃"),
    INVALID(30, "失效"),
    CLOSE(40, "已关闭");

    private final int key;
    private final String value;

    TaskStatusEnum(int key, String value) {
        this.key = key;
        this.value = value;
    }

    // 根据key获取枚举
    public static String getEnumByKey(int key) {
        String value = "";

        for (TaskStatusEnum temp : TaskStatusEnum.values()) {
            if (temp.getKey() == key) {
                value = temp.getValue();
            }
        }

        return value;
    }

    // 将枚举组成Map
    public static Map<Integer, String> getEnumList() {
        Map<Integer, String> map = new HashMap<>();

        for (TaskStatusEnum temp : TaskStatusEnum.values()) {
            map.put(temp.getKey(), temp.getValue());
        }

        return map;
    }

    public int getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }
}
